package com.yeepay.skb.biz;


import com.yeepay.skb.util.Conts;
import org.apache.commons.httpclient.methods.multipart.Part;
import org.apache.commons.httpclient.methods.multipart.StringPart;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 分润查询接口
 */
public class AccountTradeQueryPartsBuilder extends YeepayBuilder{
    protected List<Part> parts=new ArrayList<Part>();
    protected String url= Conts.baseRequestUrl + "/queryTradeInfo.action";
    private ArrayList<String> needHmac=new ArrayList<>(Arrays.asList(
            "mainCustomerNumber",
            "customerNumber",
            "splitterType",
            "beginDate",
            "endDate",
            "orderNo",
            "pageNo"
    ));

    public Part[] generateParams() {
        return parts.toArray(new Part[parts.size()]);
    }

    public AccountTradeQueryPartsBuilder setMainCustomerNumber(
            String mainCustomerNumber) {
        this.parts.add(new StringPart("mainCustomerNumber",
                mainCustomerNumber == null ? "" : mainCustomerNumber, "UTF-8"));
        return this;
    }

    public AccountTradeQueryPartsBuilder setCustomerNumber(String customerNumber) {
        this.parts.add(new StringPart("customerNumber",
                customerNumber == null ? "" : customerNumber, "UTF-8"));
        return this;
    }

    public AccountTradeQueryPartsBuilder setOrderNo(String orderNo) {
        this.parts.add(new StringPart("orderNo",
                orderNo == null ? "" : orderNo, "UTF-8"));
        return this;
    }

    public AccountTradeQueryPartsBuilder setBeginDate(String beginDate) {
        this.parts.add(new StringPart("beginDate", beginDate == null ? ""
                : beginDate, "UTF-8"));
        return this;
    }

    public AccountTradeQueryPartsBuilder setEndDate(String endDate) {
        this.parts.add(new StringPart("endDate",
                endDate == null ? "" : endDate, "UTF-8"));
        return this;
    }

    public AccountTradeQueryPartsBuilder setPageNo(String pageNo) {
        this.parts.add(new StringPart("pageNo", pageNo == null ? "" : pageNo,
                "UTF-8"));
        return this;
    }

    public AccountTradeQueryPartsBuilder setSplitterType(String splitterType) {
        this.parts.add(new StringPart("splitterType", splitterType == null ? ""
                : splitterType, "UTF-8"));
        return this;
    }

    public void setHmac(String hmac) {
        this.parts
                .add(new StringPart("hmac", hmac == null ? "" : hmac, "UTF-8"));
    }

    @Override
    public List<String> needHmacArr() {
        return needHmac;
    }

    public List<Part> getParts() {
        return parts;
    }

    @Override
    public String getUrl() {
        return url;
    }
}
